﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KandaAlpha.Domain.Model.Entities;
using KandaAlpha.Domain.Repository;
using System.Data.Objects;
using System.Data;
using System.Data.Objects.DataClasses;
using System.Linq.Expressions;
using System.Threading;
using System.Web;

namespace KandaAlpha.Infrastructure.Repository.EF
{
    // TODO - allow for bool SaveChangesWhenScopeCompletes
    public class RepositoryContext : IRepositoryContext
    {

        /// <summary>
        /// Returns the active object context
        /// </summary>
        private ObjectContext ObjectContext
        {
            get
            {
                return ObjectContextManager.GetObjectContext();
            }
        }

        public int SaveChanges()
        {
            return this.ObjectContext.SaveChanges();
        }

        public void Terminate()
        {
            ObjectContextManager.SetRepositoryContext(null);
        }

    }
}
